package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringFeedBackReplyForTeamView;
import com.cloudsigns.factorymanager2.engineering.model.EngineeringFeedBackReplyForTeamModel;
import com.cloudsigns.factorymanager2.engineering.model.IEngineeringFeedBackReplyForTeamModel;

/**
 * Created by tony on 2018/6/9.
 */

public class EngineeringFeedBackReplyForTeamPresenter {
    private IEngineeringFeedBackReplyForTeamView view;
    private IEngineeringFeedBackReplyForTeamModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public EngineeringFeedBackReplyForTeamPresenter(IEngineeringFeedBackReplyForTeamView view) {
        this.view = view;
        this.model = new EngineeringFeedBackReplyForTeamModel();
    }

    public void engineeringFeedBackRply() {


        model.engineeringFeedBackRply(view.getContent(), view.getDailyFeedbackId(), view.getOrderId(), view.getType(), new EngineeringFeedBackReplyForTeamModel.OnEngineeringFeedBackReplyListener() {
            @Override
            public void engineeringFeedBackReplySuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.engineeringFeedBackRplySuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void engineeringFeedBackReplyFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.engineeringFeedBackRplyFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
